<extend name='Index/index' />

<block name="main">

        <div id="tou">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="<{:U('Index/index')}>">首页</a>
        </li>
        <li>》</li>
        <li class="active">添加前台用户</li>
    </div>
    
    <div id="tab-add">
    <form action="<{:U('User/insert')}>" name="getForm" method="post">
        <table border="0" width="500">
            <tr>
                <td width="69" height="35">用户名</td>
              <td width="415"><input type="text" name="number"><span class="yhm"></span></td>
            </tr>
            <tr>
                <td height="39">密码</td>
              <td><input type="password" name="pwd"><span class="mima"></span></td>
            </tr>
            <tr>
                <td height="40">身份</td>
                <td>
                    <select name="identity">
                        <option value="0">普通会员</option>
                        <option value="1">超级会员</option>
                    </select>
                </td>
            </tr>
             <tr>
                <td height="38"></td>
               <td><input type="submit" value="确认添加"></td>
            </tr>
        </table>
        </form>
    </div>
    
<script src="__PUBLIC__/js/jquery.min.js"></script>
     <script>
        $(function(){

            //验证用户名
            var number = document.getForm.number;
            number.onblur = num;
                function num(){
                      var number1 = document.getForm.number.value;
                      if (number1.match(/^\w{6,12}$/) == null) {
                           $('#tab-add .yhm').css('color','red').html('× 用户名不合法');
                            return false;
                        }else{
                            $('#tab-add .yhm').css('color','red').html('');
                             return true;
                        }
               }

            var pwd = document.getForm.pwd;
            pwd.onblur = pwdd;
               function pwdd(){
                var pwd1 = document.getForm.pwd.value;
                 if (pwd1.length < 6 || pwd1.length >18) {
                           $('#tab-add .mima').css('color','red').html('密码为6-18位字符');
                            return false;
                        }else{
                           $('#tab-add .mima').css('color','red').html('');
                            return true;
                        }
               }


            $('#tab-add form').submit(function(){
                    return num() && pwdd();
            })
        })
    </script>


</block>

